System and method for dynamic routing for push notifications

ABSTRACT

A system and method are described for dynamically routing push notifications to users over the most efficient network path. For example, in one embodiment, presence information associated with a device of a user is monitored. The presence information indicates whether the first device is currently connected to a wireless network and a current network location of the device. The channel quality for packets transmitted between the first device and a first gateway and between the first device and a second gateway is also monitored and is used to select between the first and second gateways when transmitting push notifications.

CLAIM TO PRIORITY

This application claims the benefit of the filing date under 35 U.S.C.§119(e), of the U.S. Provisional Application No. 61/492,893, filed onJun. 3, 2011.

BACKGROUND

1. Field of the Invention

This invention relates generally to the field of mobile deviceprocessing; and more specifically, to the management of notificationmessages transmitted between mobile devices and application providers.

2. Description of the Related Art

Users of the mobile devices (laptops, palmtops, mobile phones, smartphones, multimedia phones, portable media players, GPS units, mobilegaming systems, etc.) may have applications installed that periodicallyreceive notification messages from notification services. For example,such applications include “push” e-mail services (e.g., MobileMe,Microsoft Exchange, ActiveSync, Push-IMAP, Yahoo! Push, etc.), or otherpush services (e.g., update/upgrade services, news services, web blogservices, podcast services, social networking services, or other typesof services where notification messages may be sent). Notificationmessages typically represent events of interest, which are typicallydefined by the applications (e.g., new e-mail indicator, new news itemindicator, new podcast indicator, change of on-line status of a socialnetworking friend, etc.).

The increase in the use of mobile devices magnifies the complexity ofrouting notification messages to those devices. One problem is thatmobile devices are not inherently addressable; for example, there iscurrently no mobile version of IPv6. In other words, mobile devices donot have their own IP addresses in the same way that a desktop computer,or even a laptop computer, has an IP address. Furthermore, mobiledevices are sometimes logically behind a service provider firewall thatlikely employs network address translation (NAT). Such firewalls areapplicable both within the cellular context and the wi-fi context. Giventhat mobile devices are not inherently addressable, it is difficult toroute messages to a mobile device, particularly on a large scale.

Scalability becomes a particular issue within the context ofnotification messages sent to mobile devices as the number of mobiledevices connected to a network increases. For example, a network devicethat connects to mobile devices can typically manage device connectionsfor thousands of mobile devices at a time. Thus, to accommodate hundredsof millions of mobile devices would require hundreds of thousands ofnetwork server devices to manage the connections and the routing ofmessages to those hundreds of millions of devices. Of course, hundredsof thousands of network server devices would be both cost prohibitiveand very complex to implement. Additionally, static routing of messagesusing network server devices are often not failsafe or fault tolerant,meaning that if a network device goes down, it is possible thatnotification messages will not be able to reach certain mobile devices.

BRIEF DESCRIPTION OF THE DRAWINGS

A better understanding of the present invention can be obtained from thefollowing detailed description in conjunction with the followingdrawings, in which:

FIG. 1 is a block diagram illustrating a system according to variousembodiments.

FIG. 2 is a block diagram, according to various embodiments.

FIG. 3 is a flow diagram of operation, according to various embodiments.

FIG. 4 is a flow diagram of operation, according to various embodiments.

FIG. 5 illustrates one embodiment of a system architecture for selectingan optimal route over a gateway between a provider and a device.

FIG. 6 illustrates one embodiment of a method for selecting an optimalroute over a gateway between a provider and a device.

FIG. 7 illustrates one embodiment of a system architecture for providingtwo-way push notifications.

FIG. 8 illustrates one embodiment of a method for providing two-way pushnotifications.

SUMMARY

A system and method are described for dynamically routing pushnotifications to users over the most efficient network path. Forexample, in one embodiment, presence information associated with adevice of a user is monitored. The presence information indicateswhether the first device is currently connected to a wireless networkand a current network location of the device. The channel quality forpackets transmitted between the first device and a first gateway andbetween the first device and a second gateway is also monitored and isused to select between the first and second gateways when transmittingpush notifications.

DETAILED DESCRIPTION Embodiments of a Push Notification Service

Embodiments of the invention may be implemented within the context of apush notification service. One such service, which has been designed bythe assignee of the present application, is described in co-pending U.S.Patent Application No. 2010/0227632, Filed Jun. 5, 2009, entitled PushNotification Service. An overview of the push notification service isprovided below, followed by a detailed description of a system andmethod for implementing two-way push notifications and a system andmethod for dynamic routing.

FIG. 1 is a block diagram according to various embodiments. Forwarding anotification message from a provider 102 to a mobile device 130 requiresat least one gateway 110 and one courier 120. Gateway 110 receivesnotification messages (e.g., push messages) from provider 102. Invarious embodiments, provider 102 sends an authentication Secure SocketsLayer (SSL) certificate upon an initial connection with gateway 110.This SSL certificate can be configured with additional user-defineddata. Other secure communications protocols (e.g., cryptographicprotocols such as Transport Layer Security (TLS), etc.) can be used inother embodiments. Authenticator 114 uses any additional user-defineddata to identify the provider 102 in a trusted fashion.

Where a provider associated with a particular application (e.g.,Twitter) includes additional identifying (e.g., user-defined) datawithin the SSL certificate, gateway 110 can not only authenticate theprovider, but also automatically provision push service for the providerand the application (e.g., Twitter). In other words, gateway 110 canautomatically extract any additional identifying data from theauthentication certificate and attach the additional identifying data(or a portion of the data) to messages (e.g., push-notificationmessages). In some embodiments, the additional identifying data mayidentify a topic or feed associated with the provider (or an applicationof the provider) to which a user might subscribe. Thus, the additionalinformation in the authentication certificate can be leveraged to directmessages to mobile devices that have subscribed to the topic/feed orrequested information regarding the topic/feed. In this way, pushservice is automatically provisioned for the provider.

Having received a notification message from an authenticated provider102, gateway 110 determines the destination zone for the notificationmessage. The destination zone is included within a token that is sentalong with the notification message. In some embodiments, it is notnecessary to send the zone information as part of a token. By extractingthe zone from the token or otherwise obtaining the zone information,gateway 110 determines whether the destination zone matches the zonemaintained/managed by gateway 110. So, for example, if gateway 110 isresponsible for zone 5, then all messages received from a providerhaving the destination zone 5 can be forwarded to a courier by gateway110. However, if gateway 110, which is responsible for zone 5, receivesa message whose destination zone is zone 8, then gateway 110 must routethe notification message to the gateway that is responsible for zone 5.

Routing table 112 is used to route messages from one gateway to anothergateway. In various embodiments, DNS (domain name service) is used toroute messages between gateways. However, other routing protocols couldbe used in other embodiments. Thus, when a message is received atgateway 110, gateway 110 determines whether it is the appropriategateway to forward the message. If not, gateway 110 performs a routingtable lookup of routing table 112 to determine the appropriate gatewayto forward the message. In some embodiments, the DNS lookup itself isused to determine whether the gateway is the appropriate gateway forforwarding the notification message.

In cases where gateway 110 receives a message having a particulardestination zone that matches the zone managed by gateway 110, thengateway 110 can forward that message directly to the appropriate courierdevice using a device/courier mapping 116. Gateway 110 receives thismapping information from various couriers, which will be explained inmore detail below. Zones are dynamically assigned to gateways. In otherwords, gateway 110 might manage notification messages for one zone for aperiod of time and then be switched, or reconfigured, to manage theforwarding of messages for a different zone at a later time.

Courier 120, similar to gateway 110, is a network device. Courier 120includes a connection module 124, a back-propagation module 122, andmaintains device information 126. Courier 120 can, in some embodiments,manage connections for upwards of 1.6 million devices. Couriers are notlimited to connecting with devices of a particular zone. In other words,courier 220 can manage device connections where various connecteddevices belong to different zones.

When a device initially connects with courier 120, courier 120provisions a zone for the device. In various embodiments, the zoneprovisioned for the device is permanent. Despite the particular zoneassignment for each device, devices may lose their connection withcourier 120 for various reasons. For example, a connection might be lostdue to loss of cellular signal, or wi-fi signal, loss of power, orbecause the mobile device has changed geographic locations, etc. When amobile device attempts to reconnect to the system and connect with acourier, the device can connect with any courier on the network. In thisway, courier 120 can be connected to devices assigned to differentzones.

As mentioned above, courier 120 maintains device information 126 foreach device with which it is connected. Device information can include azone identifier for the device, a unique device identifier (UID) for thedevice, and other device information. Connection module 124 is used toestablish connections between courier 120 and various devices.

Courier 120 also includes a back-propagation module 122.Back-propagation module 122 is used to back-propagate the deviceinformation 126 to respective gateways. Device information isback-propagated to gateways based on zone information. For example, ifcourier 120 is connected to a zone 11 device, then courier 120 willprovision a connection via connection module 124 with the gatewayresponsible for managing zone 11. Courier 120 will then back-propagatethe device information for the zone 11 device to the gateway responsiblefor managing zone 11. In similar fashion, courier 220 will makeconnections with gateways of different zones to back-propagate specificdevice information for devices associated with those respective zones.

Mobile device 130 includes a processor 140, memory 132, a transmitter134, a receiver 136, and one or more applications 138. Processor 140includes a connection module 142 that determines a courier forconnecting to the mobile device 230. Connection module 142 may use around-robin DNS (Domain Name Service) scheme to determine a courier withwhich to connect. In other embodiments, a courier might be determinedbased on other information, such as geographical location, etc. Receiver136 receives a zone identifier from the courier upon initiallyconnecting with the courier. Encryption module 144 combines the zoneidentifier and the unique device identifier (UID) for the device togenerate a device token. In various embodiments, encryption module 144encrypts the token by applying a hashing algorithm (e.g., SHA-0, SHA-1,SHA-2, MD5, Whirlpool, or other hashing algorithms). Memory 132 storesthe token. The token generated and encrypted by device 130 remainsconstant for mobile device 130 in various embodiments. In other words,the UID does not change and the zone identifier for the device does notchange, either.

Once the token has been generated and encrypted, transmitter 234transmits, or sends, the token to various provider applications (e.g.,provider 102). The token may be transmitted when device 130 first callsprovider 102. Provider 102 can use the token, or include the token, withany notification message so that it can be appropriately forwarded backto device 130.

FIG. 2 is a block diagram, according to various embodiments. Inparticular, FIG. 2 illustrates various examples of forwardingnotification messages between providers and mobile devices. In oneexample, device 1 subscribes to a particular application managed byprovider 1 and desires to receive notification messages for thatapplication. Thus, device 1 calls provider 1 and transmits its devicetoken to provider 1. As discussed above, that token includes anencrypted combination of the device's UID and its zone identifier. Asshown in FIG. 2, device 1 has a zone identifier, zone 15. Thus, whenprovider 1 sends a notification message to device 1, it connects withone of the gateways in the system. In various embodiments, provider 1connects to a gateway via round-robin DNS, although, in otherembodiments, other connection schemes can be used. However, it isimportant to note that provider 1 does not need to connect to anyparticular gateway to successfully push a notification message to device1. For example, if provider 1 usually connects with gateway 1 and sendsa message intended for device 1, gateway 1 will look at the tokenaccompanying the message and see that the message is intended for adevice in zone 15. Given that gateway 1 is associated with zone 9,gateway 1 performs a routing table lookup (e.g., DNS lookup) and routesthe message to gateway 2, which is responsible for zone 15.

Gateway 2 sends/forwards the message to courier 2 based on itsdevice/courier mapping. Given that courier 2 is connected to device 1,courier 2 will have previously back-propagated the device informationfor device 1 to gateway 2 because device 1 belongs to zone 15 andgateway 2 is responsible for managing zone 15. Thus, gateway 2 is ableto forward a message to courier 2, based on its device courier mapping;courier 2 is then able to lookup its connections and send the message todevice 1.

Note in FIG. 2 that courier 2 is connected to both device 1 and device 2and that each device belongs to a different zone. Thus, courier 2back-propagates device information for each of the devices to theappropriate zone for the respective devices. In other words, courier 2back-propagates device information for device 1 to gateway 2, given thatgateway 2 manages zone 15. Courier 2 back-propagates device informationfor zone 2 to gateway 1, given that gateway 1 is responsible formanaging zone 9. As mentioned above, back-propagation involves a courierestablishing a connection with a gateway device and sending informationas to its connections with various mobile devices (e.g., UIDs for thedevices).

In another example, provider 2 wishes to send a notification message todevice 3. Assume that provider 2 establishes a connection with gateway1; thus, when provider 2 sends the message to gateway 1, gateway 1determines that it is the appropriate gateway to forward the message,given that the message is intended for a zone 9 device (gateway 1 isresponsible for zone 9). It can be seen from FIG. 2 that gateway 1 hasconnections with both courier 1 and courier 2, given that both courier 1and courier 2 are each connected to a zone 9 device. However, based onthe device/courier mappings back-propagated by courier 1 and courier 2,respectively, gateway 1 can perform a lookup of the mapping informationand determine that the message should be forwarded to courier 1 in orderto reach its destination at device 3. Once courier 1 receives themessage, courier 1 forwards the message to device 3.

FIG. 3 is a flow diagram of operation, according to various embodiments.Presence information for one or more mobile devices is dynamicallyreceived 310 from respective couriers connected to the mobile devices.The presence information for each mobile device includes a tokencomprised of a UID and a zone identifier. The term “dynamicallyreceiving” as used herein refers to the concept that the presenceinformation is not static. In other words, devices are not alwaysconnected to the same couriers and, therefore, gateways need to bedynamically updated to appropriately forward messages for devices to thecorrect couriers.

The notification message is received 320 at the first gateway devicefrom a provider application. The notification message includes a mobiledevice token. The token is decrypted 330 (e.g., using a hashingalgorithm) to determine the zone identifier associated with the message.It is then determined 340 whether the zone identifier in the messagematches the zone currently managed by the gateway. If the zoneidentifier in the message does not match the zone managed by gateway,the gateway performs a routing table lookup and routes 360 the messageto the appropriate gateway that manages the zone associated with themessage. If the zone identifier in the message does match the zonemanaged by the gateway, the gateway refers to its device/courier mappingand forwards 350 the message to the appropriate courier.

FIG. 4 is a flow diagram of operation, according to various embodiments.A mobile device establishes 410 a connection to a courier device. Theconnection can be established by performing a round-robin DNS search, orother scheme, to establish a courier connection. A zone identifier isreceived 420 from the courier device upon connecting with the courierdevice. In various embodiments, the zone identifier is received onlyduring an initial connection with the courier. In other words, a zoneidentifier is not received each time the device connects with a newcourier. Instead, the zone identifier is received only the first timethe device makes a connection of any kind with a courier.

A token for the device is generated and encrypted 430 via an encryptionalgorithm. The token includes both the device's unique identifier (UID)and the zone identifier. The encryption may be accomplished using ahashing algorithm, such as the hashing algorithms described previously.Once the token has been generated and encrypted, the token istransmitted 440 to a provider application. For example, the user of themobile device might download, install, and/or subscribe to a particularapplication (e.g., Twitter). In some embodiments, when the mobile devicenext calls that provider application, it transmits the token to theprovider 440. The transmittal of the token could also occur, forexample, at the time the user subscribes and/or signs up for theapplication or service.

Subsequently, a message is received 450 from the provider applicationvia a path that includes at least one gateway and a courier. In otherwords, the path might include one gateway, or more than one gateway.However, in various embodiments, the path will include only one courier.The forwarding path between gateway(s) and courier is determined based,at least in part, on the token that was originally transmitted from thedevice to the provider application.

Embodiments of a System and Method for Two-Way Push Notifications

As discussed above, in one embodiment, providers push notifications tomobile devices through gateways and couriers. As illustrated in FIG. 5,on one side of the architecture, the mobile devices D₁ and D₂ registerto receive push notifications by establishing a secure connection to aparticular courier 531, 532 (e.g., an SSL or TLS connection). Asmentioned above, the couriers 531, 532 maintain network information foreach device including, for example, a zone identifier and a uniquedevice identifier (UID) for each device. The zone identifier identifiesthe particular zone to which the device is assigned which, in turn,identifies the gateway responsible for that zone.

In the particular example shown in FIG. 5, gateways 521 and 523 areresponsible for routing push notifications for zones 1-500, and gateways522-524 are responsible for routing push notifications for zones501-1000. Multiple gateways are assigned to handle traffic for the samerange of zones to provide redundancy, load balancing, and dynamic datatraffic routing (as described herein). For example, if gateway 323becomes inoperative, its data traffic (for zones 1-500) may betemporarily serviced by gateway 521. It should be noted, however, thatthe underlying principles of the invention are not limited to anyparticular number of gateways or any particular set of zone assignments.

In one embodiment, the different gateways may be located in differentdata centers. For example, gateways 521 and 522 may be located in afirst data center and gateways 523 and 524 may be located in a seconddata center. Multiple redundant gateways may also be located within thesame data center. The underlying principles of the invention may beimplemented within a single data center or across multiple data centers.

As illustrated in FIG. 5, a provider 501 may connect to a gatewaythrough a particular interface 511, which performs an analogous functionas couriers perform for mobile devices. Each interface 511 is a processthrough which providers 501 may securely transmit push notifications viaSSL or TLS connections (i.e., as authorized by users via applicationsexecuted on the mobile devices). For example, a user may register toreceive push notifications for a particular news topic or team, or forany other application-specific reason. The providers 501 generate thesepush notifications at appropriate times (e.g., periodically, in responseto certain events, etc) based on user preferences.

A device's presence information is maintained on the gateways using thedevice's push token. Accordingly, when a push notification is receivedat a gateway directed to a particular push token, the gateway performs alookup to determine there is a TCP socket descriptor associated withthat push token. The socket descriptor provides the TCP socketinformation and other networking information needed to transmit the pushnotification to the appropriate courier 531 (i.e., the courier throughwhich the device is currently connected).

A provider identifies a device using the device's push token (e.g.,token T₁ in the example, which identifies device D₁). The push tokencontains a zone identifier indirectly identifying the gatewayresponsible for that zone (i.e., because each gateway is responsible forrouting traffic for a specified range of zones). In the example shown inFIG. 5, token T₁ associated with device D₁ identifies zone 506, which ismanaged by two redundant gateways: gateways 522 and 524.

Thus, in the example shown in FIG. 5, push notifications may betransmitted to device D₁ through either of the gateways 522 or 524. Inone embodiment of the invention, a round robin scheme is employed tobalance the load between each of the gateways. Alternatively, or inaddition, the quality of the communication channel between each gatewayand each device may be monitored, and the gateway which provides arelatively higher quality connection may be selected. While variousdifferent measurements may be used to determine the “quality” of eachgateway/device channel, in one embodiment of the invention, the qualityis based on the measured round trip time for packets transmitted betweeneach gateway and each device. Thus, as indicated in FIG. 5, a currentround trip times (RTT) value associated with each device may be storedand subsequently used to select a particular route through a particulargateway. Given that each of the redundant gateways (521/523 and 522/524)may be located in different data centers, the selected gateway may tendto be in the same data center as the courier to which the device iscurrently attached (although the underlying principles of the inventionare not limited to this particular implementation).

In one embodiment, an interface 511 of a provider 501 may initially makea domain name service (DNS) call to identify the network addresses(e.g., IP addresses) of each of the gateways needed to route aparticular push notification. As previously described, a push token suchas T₁ in our example identifies a zone, and that zone identifies aparticular set of gateways (i.e., in our example, zone 506 identifiesredundant gateways 522 and 524). Thus, the interface 511 may initiallygenerate a DNS query of the form 6.gateway.push.apple.com (i.e., wherethe 6 in the first portion of the address identifies zone 6). The DNSserver then responds to the interface query with the IP addresses ofeach of the gateways 522 and 523 responsible for zone 6. The interface511 may then select one of the gateways to transmit the pushnotification.

In one embodiment, the interface 511 selects a particular gateway basedon the current round trip time (RTT) associated with that gateway forthe particular device to which the push is directed. For example, ifgateway 522 has a relatively shorter RTT than gateway 524, then theinterface 511 may select gateway 522. Alternatively, instead of theinterface selecting a gateway with a relatively lower RTT, the networkaddress of the gateway having the lowest RTT may be provided to theinterface in response to the DNS query, or the set of network addressesmay be sent to the interface in a prioritized order (with the networkaddress of the gateway having the lowest RTT at the top of theprioritized list). In this embodiment, the DNS may be integrated with,or may communicate with, each of the gateways to retrieve and processthe various RTT values. It should be noted, however, that the underlyingprinciples of the invention are not limited to the specific manner inwhich a route is selected through a gateway. Various differentconfigurations are possible and contemplated within the scope of thepresent invention.

In addition to routing based on RTT values, in one embodiment, a roundrobin scheme may also be implemented (e.g., for load balancing). Forexample, as long as the RTT values associated with each of the gatewaysis within a specified threshold, then either gateway may represent aviable routing option. In such a case, a gateway next in succession inthe round robin scheme may be selected. In one embodiment, the roundrobin scheme may be performed with only those gateways having RTT valueswithin the designated threshold. For example, if there are eightdifferent possible gateways, but only two that have RTT values withinthe threshold, then the round robin scheme may be implemented betweenjust the two gateways. This embodiment may be particularly advantageouswhen there are multiple gateways within the same data center responsiblefor the same zone or zone range. In such a case, the two gateways mayhave relatively similar RTT values, but these RTT values may besignificantly lower than the remaining 6 gateways (which may be indifferent data centers). It should be noted, of course, that theunderlying principles of the invention are not limited to any particulardistribution of gateways between data centers.

In one embodiment, the RTT is not compared to a static threshold value.Rather, the differences between the various RTT values are compared and,if some are significantly lower than others beyond a specified thresholddifference, then the gateways with the lower RTT values will beselected.

One embodiment of a method for routing push notifications is illustratedin FIG. 6. The method may be implemented within the context of thearchitecture shown in FIG. 5, but is not limited to any particularsystem architecture.

At 601, presence information is received from a particular mobiledevice, identifying the device to the push notification service (e.g.,identifying the particular courier through which the device isconnected). As mentioned above, in one embodiment, the device's token isassociated with a socket descriptor identifying a TCP socket connectingeach gateway to each courier which, in turn, maintains a connection withthe device.

At 602, round trip times (RTTs) are monitored between each of thedevices and each of the gateways. In one embodiment, the RTT values foreach GW/device combination are continually updated within a tablemanaged by the gateways, although such a configuration is not necessaryfor complying with the underlying principles of the invention.

At 603, a push notification is generated by a particular provider withwhich the user has subscribed. For example, a particular event may occurwith respect to one of the user's favorite teams or a new version ofsoftware installed on the user's device may be made available.

At 604, a route is chosen to route the push notification through aparticular gateway. As previously mentioned, the route may be indicatedin response to a DNS query by the interface through which the provideris connected or, alternatively, may be made by the interface itself.Additionally, a limited round robin scheme may be implemented incombination with the RTT values (as discussed above). Regardless of theparticular implementation, a gateway be selected to efficiently routethe push notification to the device.

System and Method for Two-Way Push

The above discussion focused on a unidirectional implementation in whichpush notifications generated by providers are routed to mobile devices.In addition, one embodiment of the invention opens a push channel fromdevices to providers, thereby enabling bi-directional push communicationbetween providers and devices. A bi-directional implementation may beused, for example, to generate feedback notifications to providers(e.g., using read receipts to detect when a user has read, acknowledged,or otherwise consumed a push notification).

Referring to FIG. 7, in one embodiment, an provider opens a socketconnection to a pre-specified TCP port via interface 711 in order toindicate that the provider is listening for notifications. In theexample shown in FIG. 7, this port is generically referred to as “PortX,” although any pre-specified port may be used. For authenticationpurposes, each provider is assigned a unique certificate which may beused to generate a zone number for the provider. In one embodiment, theprovider provides its certificate to the interface, which then performsa hash on the certificate (e.g., an SHA-1 hash [we didn't discuss theparticular hash—feel free to correct or elaborate. —TW]) to generate aprovider token (analogous to the device token) which includes a zonenumber—zone 518 in the example shown in FIG. 7. This token/zone numbermay then be specified by applications on mobile devices (or by otherservices) to transmit push notifications to each respective provider.

Consequently, just as couriers register the presence of devices withgateways (as discussed above), each provider may register its presencewithin the gateway responsible for its zone. As indicated in FIG. 7, theprovider's presence data is stored on a table on each gatewayresponsible for the provider's assigned zone. As indicated, the presenceinformation may include the round trip times (RTTs) of packetstransmitted between the gateway and each respective provider. The RTTvalues associated with providers may then be used to select among eachof the redundant gateways for a zone, just as the RTT values forcouriers are used to select gateways as described above. It should benoted that, although not illustrated in FIG. 7, the same providerpresence and device presence as shown for gateway 524 may be storedwithin gateway 522.

A device transmitting a push notification to a particular provideridentifies that provider with the provider's token, which identifies thegateway using the zone associated with that token. In one embodiment,the courier to which the device is connected initially extracts theprovider's zone number from the provider's token and generates a DNSquery using the zone number to identify the IP addresses of the gatewaysresponsible for that zone (e.g., 518.gateway.push.apple.com, where 518identifies the zone). The DNS functionality may be implemented withinthe same hardware platforms as the gateways or may use separate,dedicated hardware. Multiple IP addresses may then be returned inresponse to the DNS queries for multiple redundant gateways. In oneembodiment, these IP addresses may be prioritized using a round robinscheme, RTT values or a combination of the two (as discussed above). Forexample, if a set of gateways have RTT values significantly lower thanother gateways for this particular provider (e.g., lower by a specifiedthreshold amount), then the round robin scheme may be implemented onthis set of gateways.

Regardless of how the gateways are prioritized, the selected gatewayuses the socket descriptor data for the interface to which the provideris connected to transmit the push notification to the provider. Theprovider may then read the contents of the push notification and respondin any application-specific manner. For example, if the pushnotification is a read receipt, then the provider may store theinformation contained in the read receipt within a user database. Ofcourse, the underlying principles of the invention are not limited toany particular use of the reverse-push functions described herein.Moreover, the same provider may be connected over several differentgateways to several different interfaces while still complying with theunderlying principles of the invention.

FIG. 8 illustrates a method according to one embodiment of theinvention. The method may be executed within the context of thearchitecture shown in FIG. 7, but is not limited to any particulararchitecture.

At 801, the provider connects to the push notification service via adesignated port (e.g., Port X in the example shown in FIG. 7) andprovides its certificate. At 802, a hash of the certificate is performedto identify the zone for the provider. At 803, the provider's presencedata (e.g., TCP socket data and current status) is stored within thegateways responsible for this particular zone. At 804, a pushnotification is received from one of the devices and the route through aparticular gateway is selected based on the current quality of thesocket connections over each of the gateways (e.g., as identified byround trip times, in one embodiment). Finally, at 805, the reverse pushnotification is received by the provider, which may act on the receiptof the reverse push notification in any number of pre-specified ways.

Embodiments of the invention may include various steps as set forthabove. The steps may be embodied in machine-executable instructionswhich cause a general-purpose or special-purpose processor to performcertain steps. Alternatively, these steps may be performed by specifichardware components that contain hardwired logic for performing thesteps, or by any combination of programmed computer components andcustom hardware components.

Elements of the present invention may also be provided as amachine-readable medium for storing the machine-executable program code.The machine-readable medium may include, but is not limited to, floppydiskettes, optical disks, CD-ROMs, and magneto-optical disks, ROMs,RAMs, EPROMs, EEPROMs, magnetic or optical cards, or other type ofmedia/machine-readable medium suitable for storing electronic programcode.

Throughout the foregoing description, for the purposes of explanation,numerous specific details were set forth in order to provide a thoroughunderstanding of the invention. It will be apparent, however, to oneskilled in the art that the invention may be practiced without some ofthese specific details. For example, it will be readily apparent tothose of skill in the art that the functional modules and methodsdescribed herein may be implemented as software, hardware or anycombination thereof. Moreover, although embodiments of the invention aredescribed herein within the context of a mobile computing environment(i.e., using mobile devices 120-123; 601-603), the underlying principlesof the invention are not limited to a mobile computing implementation.Virtually any type of client or peer data processing devices may be usedin some embodiments including, for example, desktop or workstationcomputers. Accordingly, the scope and spirit of the invention should bejudged in terms of the claims which follow.

1. A method for dynamically routing push notifications to a mobiledevice comprising: receiving an indication that a first user of a firstmobile device has selected to receive push notifications from a firstprovider; monitoring presence information associated with the firstuser, the presence information indicating whether the first device iscurrently connected to a wireless network and a current network locationof the first device; monitoring channel quality for packets transmittedbetween the first device and a first gateway and between the firstdevice and a second gateway; receiving a push notification directed tothe first user from the first provider; and selecting one of the firstand the second gateways to transmit the push notification to the firstdevice based on the measured channel quality.
 2. The method as in claim1 wherein monitoring channel quality comprises monitoring round triptimes for packets transmitted between the first device and a firstgateway and between the first device and a second gateway.
 3. The methodas in claim 2 further comprising: selecting the gateway which has arelatively lower round trip time associated therewith.
 4. The method asin claim 1 wherein if the channel quality measured between the firstdevice and the first gateway is within a specified threshold amount ofthe channel quality measured between the first device and a secondgateway, then employing a round robin scheme to select between the firstgateway and the second gateway for transmitting the push notification tothe first device.
 5. The method as in claim 1 further comprising:receiving a domain name service (DNS) query from the first provider forthe push notification.
 6. The method as in claim 5 wherein selectingcomprises providing the network address of one of the first and secondgateways to the provider in response to the DNS query based on themeasured channel quality.
 7. The method as in claim 1 furthercomprising: maintaining a provider presence table on each of the firstand second gateways, the provider presence table containing updatedpresence data for each device and channel quality value associated withthe connection between that gateway and each respective device.
 8. Themethod as in claim 7 wherein the presence data comprises an indicationas to whether each device is currently connected and listening for pushnotifications and an indication of the network socket to which eachdevice is currently connected.
 9. A machine-readable medium havingprogram code stored thereon which, when executed by one or moremachines, causes the machines to perform the operations of: receiving anindication that a first user of a first mobile device has selected toreceive push notifications from a first provider; monitoring presenceinformation associated with the first user, the presence informationindicating whether the first device is currently connected to a wirelessnetwork and a current network location of the first device; monitoringchannel quality for packets transmitted between the first device and afirst gateway and between the first device and a second gateway;receiving a push notification directed to the first user from the firstprovider; and selecting one of the first and the second gateways totransmit the push notification to the first device based on the measuredchannel quality.
 10. The machine-readable medium as in claim 9 whereinmonitoring channel quality comprises monitoring round trip times forpackets transmitted between the first device and a first gateway andbetween the first device and a second gateway.
 11. The machine-readablemedium as in claim 10 comprising additional program code to cause themachines to perform the additional operations of: selecting the gatewaywhich has a relatively lower round trip time associated therewith. 12.The machine-readable medium as in claim 9 wherein if the channel qualitymeasured between the first device and the first gateway is within aspecified threshold amount of the channel quality measured between thefirst device and a second gateway, then employing a round robin schemeto select between the first gateway and the second gateway fortransmitting the push notification to the first device.
 13. Themachine-readable medium as in claim 9 comprising additional program codeto cause the machines to perform the additional operations of: receivinga domain name service (DNS) query from the first provider for the pushnotification.
 14. The machine-readable medium as in claim 13 whereinselecting comprises providing the network address of one of the firstand second gateways to the provider in response to the DNS query basedon the measured channel quality.
 15. The machine-readable medium as inclaim 9 further comprising: maintaining a provider presence table oneach of the first and second gateways, the provider presence tablecontaining updated presence data for each device and channel qualityvalue associated with the connection between that gateway and eachrespective device.
 16. The machine-readable medium as in claim 15wherein the presence data comprises an indication as to whether eachdevice is currently connected and listening for push notifications andan indication of the network socket to which each device is currentlyconnected.
 17. A system having program code stored thereon which, whenexecuted by a processor, causes the processor to perform the operationsof: receiving an indication that a first user of a first mobile devicehas selected to receive push notifications from a first provider;monitoring presence information associated with the first user, thepresence information indicating whether the first device is currentlyconnected to a wireless network and a current network location of thefirst device; monitoring channel quality for packets transmitted betweenthe first device and a first gateway and between the first device and asecond gateway; receiving a push notification directed to the first userfrom the first provider; and selecting one of the first and the secondgateways to transmit the push notification to the first device based onthe measured channel quality.
 18. The system as in claim 17 whereinmonitoring channel quality comprises monitoring round trip times forpackets transmitted between the first device and a first gateway andbetween the first device and a second gateway.
 19. The system as inclaim 18 comprising additional program code to cause the processor toperform the additional operations of: selecting the gateway which has arelatively lower round trip time associated therewith.
 20. The system asin claim 17 wherein if the channel quality measured between the firstdevice and the first gateway is within a specified threshold amount ofthe channel quality measured between the first device and a secondgateway, then employing a round robin scheme to select between the firstgateway and the second gateway for transmitting the push notification tothe first device.
 21. The system as in claim 17 comprising additionalprogram code to cause the processor to perform the additional operationsof: receiving a domain name service (DNS) query from the first providerfor the push notification.
 22. The system as in claim 21 whereinselecting comprises providing the network address of one of the firstand second gateways to the provider in response to the DNS query basedon the measured channel quality.
 23. The system as in claim 17comprising additional program code to cause the processor to perform theadditional operations of: maintaining a provider presence table on eachof the first and second gateways, the provider presence table containingupdated presence data for each device and channel quality valueassociated with the connection between that gateway and each respectivedevice.
 24. The system as in claim 23 wherein the presence datacomprises an indication as to whether each device is currently connectedand listening for push notifications and an indication of the networksocket to which each device is currently connected